\chapter{Affine varieties as ringed spaces}
\label{ch:affine_varieties_ringed_spaces}
As in the previous chapter, we are working only over affine varieties in $\CC$ for simplicity.

\section{Synopsis}
Group theory was a strange creature in the early 19th century.
During the 19th century, a group was literally defined
as a subset of $\GL(n)$ or of $S_n$.
Indeed, the word ``group'' hadn't been invented yet.
This may sound ludicrous, but it was true -- Sylow developed his theorems without this notion.
Only much later was the abstract definition of a group given,
an abstract set $G$ which was \emph{independent} of any embedding into $S_n$,
and an object in its own right.

We are about to make the same type of change for our affine varieties.
Rather than thinking of them as an object locked into an ambient space $\Aff^n$
we are instead going to try to make them into an object in their own right.
Specifically, for us an affine variety will become a \emph{topological space}
equipped with a \emph{ring of functions} for each of its open sets:
this is why we call it a \textbf{ringed space}.

The bit about the topological space is not too drastic.
The key insight is the addition of the ring of functions.
For example, consider the double point from last chapter.

\begin{center}
	\begin{asy}
		import graph;
		size(5cm);

		real f(real x) { return x*x; }
		graph.xaxis("$x$", red);
		graph.yaxis("$y$");
		draw(graph(f,-2,2,operator ..), blue, Arrows);
		label("$\mathcal V(y-x^2)$", (0.8, f(0.8)), dir(-45), blue);
		label("$\mathbb A^2$", (2,3), dir(45));
		dotfactor *= 1.5;
		dot(origin, heavygreen);
	\end{asy}
\end{center}

As a set, it is a single point,
and thus it can have only one possible topology.
But the addition of the function ring will let us tell it apart
from just a single point.

This construction is quite involved, so we'll proceed as follows:
we'll define the structure bit by bit onto our existing affine varieties in $\Aff^n$,
until we have all the data of a ringed space.
In later chapters, these ideas will grow up to
become the core of modern algebraic geometry: the \emph{scheme}.

\section{The Zariski topology on $\Aff^n$}
\prototype{In $\Aff^1$, closed sets are finite collections of points.
In $\Aff^2$, a nonempty open set is the whole space minus some finite collection of curves/points.}

We begin by endowing a topological structure on every variety $V$.
Since our affine varieties (for now) all live in $\Aff^n$, all we have to do
is put a suitable topology on $\Aff^n$, and then just view $V$ as a subspace.

However, rather than putting the standard Euclidean topology on $\Aff^n$,
we put a much more bizarre topology.
\begin{definition}
	In the \vocab{Zariski topology} on $\Aff^n$,
	the \emph{closed sets} are those of the form
	\[ \VV(I) \qquad\text{where}\quad I \subseteq \CC[x_1, \dots, x_n]. \]
	Of course, the open sets are complements of such sets.
\end{definition}

\begin{example}
	[Zariski topology on $\Aff^1$]
	Let us determine the open sets of $\Aff^1$,
	which as usual we picture as a straight line
	(ignoring the fact that $\CC$ is two-dimensional).

	Since $\CC[x]$ is a principal ideal domain, rather than looking at $\VV(I)$
	for every $I \subseteq \CC[x]$, we just have to look at $\VV(f)$ for a single $f$.
	There are a few flavors of polynomials $f$:
	\begin{itemize}
		\ii The zero polynomial $0$ which vanishes everywhere:
		this implies that the entire space $\Aff^1$ is a closed set.
		\ii The constant polynomial $1$ which vanishes nowhere.
		This implies that $\varnothing$ is a closed set.
		\ii A polynomial $c(x-t_1)(x-t_2)\dots(x-t_n)$ of degree $n$.
		It has $n$ roots, and so $\{t_1, \dots, t_n\}$ is a closed set.
	\end{itemize}
	Hence the closed sets of $\Aff^1$ are exactly all of $\Aff^1$
	and finite sets of points (including $\varnothing$).
	Consequently, the \emph{open} sets of $\Aff^1$ are
	\begin{itemize}
		\ii $\varnothing$, and
		\ii $\Aff^1$ minus a finite collection (possibly empty) of points.
	\end{itemize}
\end{example}

Thus, the picture of a ``typical'' open set $\Aff^1$ might be
\begin{center}
	\begin{asy}
		size(6cm);
		pair A = (-9,0); pair B = (9,0);
		pen bloo = blue+1.5;
		draw(A--B, blue, Arrows);
		draw(A--B, bloo);
		// label("$\mathbb V()$", (0,0), 2*dir(-90));
		opendot((-3,0), bloo);
		opendot((-1,0), bloo);
		opendot((4,0), bloo);
		label("$\mathbb A^1$", B-(2,0), dir(90));
	\end{asy}
\end{center}
It's everything except a few marked points!

\begin{example}[Zariski topology on $\Aff^2$]
	Similarly, in $\Aff^2$,
	the interesting closed sets are going to consist
	of finite unions (possibly empty) of
	\begin{itemize}
		\ii Closed curves,
		like $\VV(y-x^2)$ (which is a parabola), and
		\ii Single points, like $\VV(x-3,y-4)$
		(which is the point $(3,4)$).
	\end{itemize}
	Of course, the entire space $\Aff^2 = \VV(0)$ and the empty set $\varnothing = \VV(1)$
	are closed sets.

	Thus the nonempty open sets in $\Aff^2$ consist of the \emph{entire} plane,
	minus a finite collection of points and one-dimensional curves.
\end{example}
\begin{ques}
	Draw a picture (to the best of your artistic ability)
	of a ``typical'' open set in $\Aff^2$.
\end{ques}

All this is to say
\begin{moral}
	The nonempty Zariski open sets are \emph{huge}.
\end{moral}
This is an important difference than what you're used to in topology.
To be very clear:
\begin{itemize}
	\ii In the past, if I said something like
	``has so-and-so property in an open neighborhood of point $p$'',
	one thought of this as saying
	``is true in a small region around $p$''.
	\ii In the Zariski topology,
	``has so-and-so property in an open neighborhood of point $p$''
	should be thought of as saying ``is true for virtually all points,
	other than those on certain curves''.
\end{itemize}
Indeed, ``open neighborhood'' is no longer really a accurate description.
Nonetheless, in many pictures to follow,
it will still be helpful to draw open neighborhoods as circles.

It remains to verify that as I've stated it, the closed sets actually form a topology.
That is, I need to verify briefly that
\begin{itemize}
	\ii $\varnothing$ and $\Aff^n$ are both closed.
	\ii Intersections of closed sets (even infinite) are still closed.
	\ii Finite unions of closed sets are still closed.
\end{itemize}
Well, closed sets are the same as affine varieties,
so we already know this!

\section{The Zariski topology on affine varieties}
\prototype{If $V = \VV(y-x^2)$ is a parabola,
	then $V$ minus $(1,1)$ is open in $V$.
	Also, the plane minus the origin is $D(x) \cup D(y)$.}

As we said before, by considering a variety $V$ as a subspace of $\Aff^n$
it inherits the Zariski topology.
One should think of an open subset of $V$ as
``$V$ minus a few Zariski-closed sets''.
For example:
\begin{example}[Open set of a variety]
	Let $V = \VV(y-x^2) \subseteq \Aff^2$ be a parabola,
	and let $U = V \setminus \{(1,1)\}$. We claim $U$ is open in $V$.
	\begin{center}
		\begin{asy}
		import graph;
		size(5cm);

		real f(real x) { return x*x; }
		graph.xaxis("$x$");
		graph.yaxis("$y$");
		draw(graph(f,-2,2,operator ..), blue, Arrows);
		label("$\mathcal V(y-x^2)$", (0.8, f(0.8)), dir(-45));

		opendot( (1,1), blue+1);
		\end{asy}
	\end{center}
	Indeed, $\tilde U = \Aff^2 \setminus \{(1,1)\}$ is open in $\Aff^2$
	(since it is the complement of the closed set $\VV(x-1,y-1)$),
	so $U = \tilde U \cap V$ is open in $V$.
	Note that on the other hand the set $U$ is \emph{not} open in $\Aff^2$.
\end{example}

We will go ahead and introduce now a definition
that will be very useful later.
\begin{definition}
	Given $V \subseteq \Aff^n$ an affine variety and $f \in \CC[x_1, \dots, x_n]$,
	we define the \vocab{distinguished open set}
	$D(f)$ to be the open set in $V$
	of points not vanishing on $f$:
	\[ D(f) = \left\{ p \in V \mid f(p) \neq 0 \right\} = V \setminus \VV(f). \]
\end{definition}
In \cite{ref:vakil}, Vakil suggests remembering the
notation $D(f)$ as ``doesn't-vanish set''.
\begin{example}
	[Examples of (unions of) distinguished open sets]
	\listhack
	\begin{enumerate}[(a)]
		\ii If $V = \Aff^1$ then $D(x)$ corresponds to a line minus a point.
		\ii If $V = \VV(y-x^2) \subseteq \Aff^2$,
		then $D(x-1)$ corresponds to the parabola minus $(1,1)$.
		\ii If $V = \Aff^2$, then
		$D(x) \cup D(y) = \Aff^2 \setminus \{ (0,0) \}$
		is the punctured plane.
		You can show that this set is \emph{not} distinguished open.
	\end{enumerate}
\end{example}
You can think of the concept as an analog to principal ideal:
all open sets can be written in the form $V \setminus \VV(I)$ for some ideal $I$,
but if $I=(f)$ is principal then the set can be written
as a distinguished open set $D(f)$.
Similarly, the intersection of two distinguished open sets is distinguished,
just as the product (not intersection!) of two principal ideals is principal.

\begin{proposition}
	[Properties of distinguished open set]
	Recall that $\VV$ is inclusion-reversing, so being the complement of $\VV$,
	we would expect $D$ to be ``inclusion-preserving''. Indeed:
	\begin{itemize}
		\item If $(f) \subseteq (g)$ (that is, $g \mid f$), then $D(f) \subseteq
			D(g)$.
		\item Recall that $(fg) \subseteq(f) \cap(g)$. For distinguished open
			set, we have $D(fg) = D(f) \cap D(g)$.
	\end{itemize}
\end{proposition}

It is useful to be familiar with the behavior of $D$.
\begin{ques}
	If $V=\AA^2$, then $D(x)$ is the plane minus the $y$-axis, and
	$D(y)$ is the plane minus the $x$-axis. What is $D(xy)$?
\end{ques}


% There used to be an exercise here about D(f)
% being a distinguished base

%\begin{ques}
%	Give an example of an open set of $\Aff^2$
%	which is not a distinguished open set.
%	(There was one above already.)
%\end{ques}


\section{Coordinate rings}
\prototype{If $V = \VV(y-x^2)$ then $\CC[V] = \CC[x,y]/(y-x^2)$.}

The next thing we do is consider the functions from $V$ to the base field $\CC$.
We restrict our attention to algebraic (polynomial) functions on a variety $V$:
they should take every point $(a_1, \dots, a_n)$ on $V$ to some complex number $P(a_1, \dots, a_n) \in \CC$.
For example, a valid function on a three-dimensional affine variety might be $(a,b,c) \mapsto a$;
we just call this projection ``$x$''.
Similarly we have a canonical projection $y$ and $z$,
and we can create polynomials by combining them,
say $x^2y + 2xyz$.

\begin{definition}
	The \vocab{coordinate ring} $\CC[V]$ of a variety $V$
	is the ring of polynomial functions on $V$.
	(Notation explained next section.)
\end{definition}

\begin{remark}
	[Meaning of the name ``coordinate ring'']
	\label{remark:meaning_name_coordinate_ring}
	We call the functions $x$, $y$ and $z$ above as the \vocab{coordinate
	functions}, as they maps each point in the variety $V$ to its coordinate.
	So, the coordinate ring $\CC[V]$ is simply the ring generated by $\CC$ and
	the coordinate functions.
\end{remark}

At first glance, we might think this is just $\CC[x_1, \dots, x_n]$.
But on closer inspection we realize that \emph{on a given variety},
some of these functions are the same.
For example, consider in $\Aff^2$ the parabola $V = \VV(y-x^2)$.
Then the two functions
\begin{align*}
	V & \to \CC \\
	(x,y) & \mapsto x^2 \\
	(x,y) & \mapsto y
\end{align*}
are actually the same function!
We have to ``mod out'' by the ideal $I$ which generates $V$.
This leads us naturally to:
\begin{theorem}[Coordinate rings correspond to ideal]
	Let $I$ be a radical ideal, and $V = \VV(I) \subseteq \Aff^n$.
	Then \[ \CC[V] \cong \CC[x_1, \dots, x_n] / I.  \]
\end{theorem}
\begin{proof}
	There's a natural surjection as above
	\[ \CC[x_1, \dots, x_n] \surjto \CC[V] \]
	and the kernel is $I$.
\end{proof}
Thus properties of a variety $V$ correspond to properties of the ring $\CC[V]$.

\section{The sheaf of regular functions}
\label{sec:sheaf_regular_functions}
\prototype{Let $V = \Aff^1$, $U = V \setminus \{0\}$. Then $1/x \in \OO_V(U)$ is regular on $U$.}

Let $V$ be an affine variety and let $\CC[V]$ be its coordinate ring.
As mentioned in the start of the chapter, we want to define a variety
based on its intrinsic properties only, which is done by studying the collection
of algebraic functions on it.

In \cite{ref:vakil} ``Motivating example: The sheaf of differentiable
functions'' section, you can see a comparison of how a differentiable manifold
can be studied by studying the differentiable functions on it.

Denote the set of all rational functions on $V$ by $\OO_V$ (as will be seen
later, this terminology is not quite accurate as we need to allow multiple
representations). We can view this as a set, however this does not capture the
full structure of the rational functions:
\begin{ques}
	For any two elements $f$ and $g$ in $\CC[V]$, show that the set where
	$\frac{f(x)}{g(x)}$ is well-defined is open in the Zariski topology.
	(Hint: $g\pre(0)$ is closed.)
\end{ques}

So, we want to define a notion of $\OO_V(U)$ for any open set $U$:
the ``nice'' functions on any open subset.
Obviously, any function in $\CC[V]$ will work as a function on $\OO_V(U)$.
However, to capture more of the structure we want to
loosen our definition of ``nice'' function slightly
by allowing \emph{rational} functions.

The chief example is that $1/x$ should be a regular function
on $\Aff^1 \setminus \{0\}$.
The first natural guess is:
\begin{definition}
	Let $U \subseteq V$ be an open set of the variety $V$.
	A \vocab{rational function} on $U$
	is a quotient $f(x) / g(x)$ of two elements $f$ and $g$ in $\CC[V]$,
	where we require that $g(x) \neq 0$ for $x \in U$.
\end{definition}
However, the definition is slightly too restrictive;
we have to allow for multiple representations:
\begin{definition}
	Let $U \subseteq V$ be open.
	We say a function $\phi \colon U \to \CC$ is a \vocab{regular function} if for
	every point $p \in U$, we can find an open set $U_p \subseteq U$ containing $p$
	and a rational function $f_p/g_p$ on $U_p$ such that
	\[ \phi(x) = \frac{f_p(x)}{g_p(x)} \qquad \forall x \in U_p. \]
	In particular, we require $g_p(x) \neq 0$ on the set $U_p$.
	We denote the set of all regular functions on $U$ by $\OO_V(U)$.
\end{definition}

Thus,
\begin{moral}
	$\phi$ is regular on $U$ if it is locally a rational function.
\end{moral}

This definition is misleadingly complicated,
and the examples should illuminate it significantly.
Firstly, in practice, most of the time we will be able to find
a ``global'' representation of a regular function as a quotient,
and we will not need to fuss with the $p$'s.
For example:
\begin{example}
	[Regular functions]
	\listhack
	\begin{enumerate}[(a)]
		\ii Any function in $f \in \CC[V]$ is clearly regular,
		since we can take $g_p = 1$, $f_p = f$ for every $p$.
		So $\CC[V] \subseteq \OO_V(U)$ for any open set $U$.
		\ii Let $V = \Aff^1$, $U_0 = V \setminus \{0\}$.
		Then $1/x \in \OO_V(U_0)$ is regular on $U_0$.
		\ii Let $V = \Aff^1$, $U_{12} = V \setminus \{1,2\}$. Then
		\[ \frac{1}{(x-1)(x-2)} \in \OO_V(U_{12}) \]
		is regular on $U_{12}$.
	\end{enumerate}
\end{example}
The ``local'' clause with $p$'s is still necessary, though.
\begin{example}
	[Requiring local representations]
	\label{ex:local_rep}
	Consider the variety
	\[ V = \VV(ab-cd) \subseteq \Aff^4 \]
	and the open set $U = V \setminus \VV(b,d)$.
	There is a regular function on $U$ given by
	\[
		(a,b,c,d)
		\mapsto
		\begin{cases}
			a/d & d \neq 0 \\
			c/b & b \neq 0.
		\end{cases}
	\]
	Clearly these are the ``same function'' (since $ab=cd$),
	but we cannot write ``$a/d$'' or ``$c/b$''
	to express it because we run into divide-by-zero issues.
	That's why in the definition of a regular function,
	we have to allow multiple representations.
\end{example}

In fact, we will see later on that the definition
of a regular function is a special case of a more
general construction called \emph{sheafification},
in which ``presheaves of functions which are $P$'' are transformed
into ``sheaves of functions which are \emph{locally} $P$''.

\section{Regular functions on distinguished open sets}
\prototype{Regular functions on $\Aff^1 \setminus \{0\}$ are $P(x) / x^n$.}
The division-by-zero, as one would expect,
essentially prohibits regular functions on the entire space $V$;
i.e.\ there are no regular functions in $\OO_V(V)$
that were not already in $\CC[V]$.
Actually, we have a more general result which computes the
regular functions on distinguished open sets:
\begin{theorem}
	[Regular functions on distinguished open sets]
	\label{thm:reg_func_distinguish_open}
	Let $V \subseteq \Aff^n$ be an affine variety
	and $D(g)$ a distinguished open subset of it.
	Then
	\[ \OO_V( D(g) ) = \left\{ \frac{f}{g^k}
		\mid f \in \CC[V] \text{ and } k \in \ZZ \right\}.  \]
	In particular, $\OO_V(V) = \OO_V(D(1)) \cong \CC[V]$.
\end{theorem}
The proof of this theorem requires the Nullstellensatz,
so it relies on $\CC$ being algebraically closed.
In fact, a counter-example is easy to find if we replace $\CC$ by $\RR$:
consider $\frac{1}{x^2+1}$.
\begin{proof}
	Obviously, every function of the form $f/g^n$ works,
	so we want the reverse direction.
	This is long, and perhaps should be omitted on a first reading.

	Here's the situation.
	Let $U = D(g)$.
	We're given a regular function $\phi$, meaning at every point $p \in D(g)$,
	there is an open neighborhood $U_p$ on which $\phi$ can be expressed
	as $f_p / g_p$ (where $f_p, g_p \in \CC[V]$).
	Then, we want to construct an $f \in \CC[V]$ and an integer $n$
	such that $\phi = f/g^n$.

	First, look at a particular $U_p$ and $f_p / g_p$.
	Shrink $U_p$ to a distinguished open set $D(h_p)$.
	Then, let $\wt f_p = f_p h_p$ and $\wt g_p = g_p h_p$.
	Thus we have that
	\[ \frac{\wt f_p}{\wt g_p} \text{ is correct on }
		D(h_p) \subseteq U \subseteq X. \]
	The upshot of using the modified $f_p$ and $g_p$ is that:
	\[ \wt f_p \wt g_q = \wt f_q \wt g_p \qquad \forall p,q \in U. \]
	Indeed, it is correct on $D(h_p) \cap D(h_q)$ by definition,
	and outside this set both the left-hand side and right-hand side are zero.

	Now, we know that $D(g) = \bigcup_{p \in U} D(\wt g_p)$, i.e.\
	\[ \VV(g) = \bigcap_{p \in U} \VV(\wt g_p). \]
	So by the Nullstellensatz we know that
	\[ g \in \sqrt{(\wt g_p : p \in U)}
		\implies \exists n : g^n \in (\wt g_p : p \in U). \]
	In other words, for some $n$ and $k_p \in \CC[V]$ we have
	\[ g^n = \sum_p k_p \wt g_p \]
	where only finitely many $k_p$ are not zero.
	Now, we claim that
	\[ f \defeq \sum_p k_p \wt f_p \]
	works.
	This just observes by noting that for any $q \in U$, we have
	\[
		f \wt g_q - g^n \wt f_q
		= \sum_p k_p(\wt f_p \wt g_q - \wt g_p \wt f_q)
		= 0. \qedhere
	\]
\end{proof}
This means that the \emph{global} regular functions
are just the same as those in the coordinate ring:
you don't gain anything new by allowing it to be locally a quotient.
(The same goes for distinguished open sets.)

\begin{example}[Regular functions on distinguished open sets]
	\listhack
	\begin{enumerate}[(a)]
		\ii As said already,
		taking $g=1$ we recover $\OO_V(V) \cong \CC[V]$
		for any affine variety $V$.
		\ii Let $V = \Aff^1$, $U_0 = V \setminus \{0\}$. Then
		\[ \OO_V(U_0)
			= \left\{ \frac{P(x)}{x^n} \mid P \in \CC[x],
			\quad n \in \ZZ \right\}. \]
		So more examples are $1/x$ and $(x+1)/x^3$.
	\end{enumerate}
\end{example}

\begin{ques}
	Why doesn't our theorem on regular functions apply to \Cref{ex:local_rep}?
\end{ques}

The regular functions will become of crucial importance
once we define a scheme in the next chapter.

\section{Baby ringed spaces}
In summary, given an affine variety $V$ we have:
\begin{itemize}
	\ii A structure of a set of points,
	\ii A structure of a topological space $V$ on these points, and
	\ii For every open set $U \subseteq V$, a ring $\OO_V(U)$.
	Elements of the rings are functions $U \to \CC$.
\end{itemize}
Let us agree that:
\begin{definition}
	A \vocab{baby ringed space} is a topological space $X$
	equipped with a ring $\OO_X(U)$ for every open set $U$.
	It is required that elements of the ring $\OO_X(U)$
	are functions $f \colon U \to \CC$;
	we call these the \emph{regular functions} of $X$ on $U$.
\end{definition}
Therefore, affine varieties are baby ringed spaces.
\begin{remark}
	This is not a standard definition. Hehe.
\end{remark}

The reason this is called a ``baby ringed space''
is that in a \emph{ringed space},
the rings $\OO_V(U)$ can actually be \emph{any rings},
but they have to satisfy a set of fairly technical conditions.
When this happens, it's the $\OO_V$ that does all the work;
we think of $\OO_V$ as a type of functor called a \emph{sheaf}.

Since we are only studying affine/projective/quasi-projective varieties
for the next chapters, we will just refer to these as baby ringed spaces
so that we don't have to deal with the entire definition.
The key concept is that we want to think of these varieties
as \emph{intrinsic objects}, free of any embedding.
A baby ringed space is philosophically the correct thing to do.

Anyways, affine varieties are baby ringed spaces $(V, \OO_V)$.
In the next chapter we'll meet projective and quasi-projective
varieties, which give more such examples of (baby) ringed spaces.
With these examples in mind, we will finally lay down
the complete definition of a ringed space,
and use this to define a scheme.

\section\problemhead

\begin{dproblem}
	Show that for any $n \ge 1$ the Zariski topology of $\Aff^n$
	is \emph{not} Hausdorff.
\end{dproblem}

\begin{dproblem}
	Let $V$ be an affine variety,
	and consider its Zariski topology.
	\begin{enumerate}[(a)]
		\ii Show that the Zariski topology is \vocab{Noetherian},
		meaning there is no infinite descending chain
		$Z_1 \supsetneq Z_2 \supsetneq Z_3 \supsetneq \dots$ of closed subsets.
		\ii Prove that a Noetherian topological space is compact.
		Hence varieties are topologically compact.
	\end{enumerate}
\end{dproblem}

\begin{sproblem}
	[Punctured Plane]
	\label{prob:punctured_plane}
	Let $V = \Aff^2$ and let $X = \Aff^2 \setminus \{(0,0)\}$ be the punctured plane
	(which is an open set of $V$).
	Compute $\OO_V(X)$.
\end{sproblem}
